<?php

class blocks extends MX_Controller
{
    public function blocks()
    {
        parent::__construct();
        $this->load->helper('text');
    }
    
    public function header()
    {
        return $this->load->view('blocks/header', array());
    }
    
    public function footer()
    {
        $this->load->model('pages_model');
        $pagemodel = new Pages_Model();
        $data = $pagemodel->getPagesById(1);
        if ($data) {
            $content = $data->contents;
        } else {
            $content = '';
        }
        return $this->load->view('blocks/footer', array('content' => $content));
    }
    
    public function nav()
    {
        return $this->load->view('blocks/nav', array('nav' => null));
    } 
    
    public function menuleft($cid = 0)
    {
     
        $this->load->model('Doc_Categories_Model');
        $navModel = new Doc_Categories_Model();
        $nav = $navModel->categoryList();
        $arr = array();
        foreach ($nav as $row) {
            $arr[$row->id][] = $row;
        }
        return $this->load->view('blocks/menu_left', array('nav' => $arr, 'cid' => $cid));
    } 
    
    public function hot()
    {
        $this->load->model('Doc_Documents_Model');
        $docModel = new Doc_Documents_Model();
        return $this->load->view('blocks/hot_in_month', array('nav' => $docModel->top_in_30day()));
    }
    
    public function rightsort()
    {
        $this->load->model('Doc_Documents_Model');
        $docModel = new Doc_Documents_Model();
        $new = $docModel->doclist(1);
        $view = $docModel->doclist(2);
        $hit = $docModel->doclist(3);
       
        return $this->load->view('blocks/rightsort', array('data' => $new, 'data1' => $view, 'data2' => $hit));
    }
    
    public function khoahoc()
    {
        $this->load->model('Doc_Documents_Model');
        $docModel = new Doc_Documents_Model();
        $data = $docModel->blockCourses();
        return $this->load->view('blocks/khoahoc', array('data' => $data));
    }
    
    public function newcomment()
    {
        $this->load->model('Doc_Documents_Model');
        $docModel = new Doc_Documents_Model();
        $data = $docModel->getLastComment();
        return $this->load->view('blocks/newcomment', array('data' => $data));
    }
}